package com.lxh.memento;


/**
 * 备忘录模式
 * Create by lxh on 2020/2/11
 */
public class Main {

    public static void main(String[] args) {
        // 初始化角色
        GameRole hero = new GameRole();
        hero.getInitState();
        hero.stateDisplay();

        // 保存进度
        RoleStateCaretaker caretaker = new RoleStateCaretaker();
        caretaker.setMemento(hero.saveState());

        // 打boss
        hero.fight();
        hero.stateDisplay();

        //恢复之前的状态
        hero.recoveryState(caretaker.getMemento());
        hero.stateDisplay();
    }
}
